<?php
/**
 * YOS News Crawler View
 *
 * @package		yos_news_crawler
 * @subpackage	Link Manager
 * @link		http://yopensource.com
 * @author		yopensource
 * @copyright 	yopensource (yopensource@gmail.com)
 * @license		Commercial
 */

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die( 'Restricted access' );

jimport( 'joomla.application.component.view');

// Set the table directory
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');

/**
 * HTML View class for the YOS News Crawler views
 *
 * @static
 * @package		YOS
 * @subpackage	YOS_News_Crawler
 * @since 1.0
 */
class YOS_NewsViewJobManager extends JView
{
	function display($tpl = null)
	{
		global $mainframe,$option;
		
		// Set the toolbar
		$this->_setToolBar();
		$model=$this->getModel('jobmanager');
		$option		= JRequest::getCmd( 'option' );
		
		$rows		= $model->getData();
		$pageNav	= $model->getPagination();
		$lists		= $model->getLists();
		
		$this->assignRef('lists',	$lists);
		$this->assignRef('rows',	$rows);
		$this->assignRef('pageNav',	$pageNav);
		$this->assign('option',		$option);
		parent::display($tpl);
	}

	function _setToolBar()
	{
		JHTML::stylesheet( 'yos_news_crawler.css', 'administrator/components/com_yos_news_crawler/assets/' );		
		JToolBarHelper::title( JText::_( 'Manager job' ).' <small>[Gold Version]</small>', 'news' );
		JToolBarHelper::publishList('jobs.publish');
		JToolBarHelper::unpublishList('jobs.unpublish');		
		JToolBarHelper::deleteList('Are you sure?','jobs.remove');
		JToolBarHelper::editListX('jobs.edit');
		JToolBarHelper::addNewX('jobs.new');
		JToolBarHelper::preferences('com_yos_news_crawler', '300');
		
		JSubMenuHelper::addEntry('Links Manager', 'index.php?option=com_yos_news_crawler&task=linkmanager', false);
		JSubMenuHelper::addEntry('Jobs Manager', 'index.php?option=com_yos_news_crawler&task=jobmanager', true);
		JSubMenuHelper::addEntry('Cms Manager', 'index.php?option=com_yos_news_crawler&task=cmsmanager', false);
		JSubMenuHelper::addEntry('Links Receive', 'index.php?option=com_yos_news_crawler&task=linkcheck', false);
		JSubMenuHelper::addEntry('Restore', 'index.php?option=com_yos_news_crawler&task=restore', false);
		JSubMenuHelper::addEntry('About', 'index.php?option=com_yos_news_crawler&task=about', false);
	}
	function edit($tpl=null)
	{
		global $mainframe,$option;
		
		$cid = JRequest::getVar( 'cid', array(0), '', 'array' );
		$cid = intval($cid[0]);
		
		$model=$this->getModel('jobmanager');
		
		$job=$model->getJob();
		$lists=$model->getList_edit();
		$script=$model->getScript();
		
//		$links=$model->getLinks();		
		$this->assignRef('job',	$job);
		$this->assignRef('lists',	$lists);
		$this->assignRef('script',	$script);

		$text = ( $cid ? JText::_( 'Edit' ) : JText::_( 'New' ) );
		
		JToolBarHelper::title( JText::_( 'Job' ).': <small><small>[ '. $text.' ]</small></small>', 'addedit.png' );
		
		JToolBarHelper::apply('jobs.apply');
		JToolBarHelper::save('jobs.save');
		if ( $cid ) {
			// for existing articles the button is renamed `close`
			JToolBarHelper::cancel( 'jobs.cancel', 'Close' );
		} else {
			JToolBarHelper::cancel('jobs.cancel');
		}
		parent::display($tpl);
	}
}
